//
//  NSObject+SLSDK.m
//  SLSDK
//
//  Created by SongLian on 16/8/7.
//  Copyright © 2016年 SongLian. All rights reserved.
//

#import "NSObject+SLSDK.h"
#import <objc/runtime.h>

@implementation NSObject (SLSDK)

- (void)sl_objc_copyNonatomic_setAssociatedObject:(id)object forKey:(NSString *)key {
    objc_setAssociatedObject(self, (__bridge const void *)key, object, OBJC_ASSOCIATION_COPY_NONATOMIC);
}

- (id)sl_objc_getAssociatedObjectForKey:(NSString *)key {
    return objc_getAssociatedObject(self, (__bridge const void *)key);
}

- (void)sl_objc_setAssociatedInteger:(NSInteger)integer forKey:(NSString *)key {
    [self sl_objc_copyNonatomic_setAssociatedObject:@(integer) forKey:key];
}

- (NSInteger)sl_objc_getAssociatedIntegerForKey:(NSString *)key {
    return [[self sl_objc_getAssociatedObjectForKey:key] integerValue];
}

@end
